/**
 * Created by afer on 2017/7/5.
 */


var CoinsDes = require('./dao').CoinsDes;
module.exports = {
    create: function (coindes) {
        coindes["coinvalue"] = 0;
        return CoinsDes.insert(coindes).exec();
    },

    getAllCoinsDes: function () {
        return CoinsDes.find().sort({_id: -1}).addCreatedAt().exec();
    },

    getCoinDesByName: function (name) {
        var query = {};
        if (name) {
            query.coinname = name;
        }
        return CoinsDes.find(query).sort({_id: -1}).exec();
    },

    getCoinDesByID: function (ID) {
        var query = {};
        if (ID) {
            query._id = ID;
        }
        return CoinsDes.find(query).sort({_id: -1}).exec();
    }
}